package cmd_domain

import (
	"fmt"
	"github.com/liuxd6825/dapr-ddd-cli/pkg/builds"
	"github.com/liuxd6825/dapr-ddd-cli/pkg/config"
	"github.com/liuxd6825/dapr-ddd-cli/pkg/utils"
)

type BuildCommand struct {
	builds.BaseBuild
	command *config.Command
}

func NewBuildCommand(base builds.BaseBuild, command *config.Command, outFile string) *BuildCommand {
	res := &BuildCommand{
		BaseBuild: base,
		command:   command,
	}
	res.TmplFile = "static/tmpl/go/init/pkg/cmd-service/domain/command/command.go.tpl"
	res.OutFile = outFile
	res.ValuesFunc = res.Values
	return res
}

func (b *BuildCommand) Values() map[string]interface{} {
	res := b.BaseBuild.ValuesOfCommand(b.command)
	return res
}

func (b *BuildCommand) Package() string {
	return fmt.Sprintf("%s_commands", utils.ToLower(b.AggregateName()))
}
